#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWidgets/QtWidgets>

MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);
}

MainWindow::~MainWindow() {
    delete ui;
}


void MainWindow::on_pushButton_clicked() {
#ifdef demo1
    QColor color = QColorDialog::getColor(Qt::white,this,"select color");
    qDebug() << "color = " << color;
#endif

#ifdef demo2
    QString filepath = QFileDialog::getOpenFileName(this,"open file","","code (*.c *.cpp *.h)");
    qDebug() << filepath;
#endif

#ifdef demo3
    bool ok;
    QFont font = QFontDialog::getFont(&ok,this);
    qDebug() << "ok = " << ok << " font = " << font;
#endif

#ifdef demo4
    bool ok;
    int value = QInputDialog::getInt(this,"get int", "please input a int", 0,-100,100,2, &ok);
    qDebug() << value << " " << ok;
#endif

#ifdef demo5
    QStringList strList = {"Caixukun","Wuyifan","Liyifeng","Dingzhen","Kobe"};
    QString result = QInputDialog::getItem(this,"select a star","please select",strList,0,false);
    qDebug() << result;
#endif


#ifdef demo6
    QMessageBox::StandardButton btn;
/*    btn = QMessageBox::information(this,"title","this is information",
                                   QMessageBox::Ok|QMessageBox::Close);*/
    btn = QMessageBox::critical(this, "title", "this is critical",
                                QMessageBox::Ok | QMessageBox::Close);
    qDebug() << btn;
#endif
}
